package com.lex.config;

import com.zaxxer.hikari.HikariDataSource;
import jakarta.annotation.PreDestroy;
import jakarta.annotation.Resource;
import org.springframework.context.annotation.Configuration;

import javax.sql.DataSource;

@Configuration
public class Myconfig {
    @Resource
    private DataSource dataSource;

    @PreDestroy
    public void cleanup() {
        if (dataSource instanceof HikariDataSource) {
            ((HikariDataSource) dataSource).close();
        }
    }
}
